package ar.com.globallogic.promomr.api.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import ar.com.globallogic.promomr.domain.Folder;
import ar.com.globallogic.promomr.services.FolderService;

@Controller
@RequestMapping("/api/library/folders")
public class FolderController {
	
	private FolderService folderService;

	@Autowired
	public FolderController(FolderService folderService) {
		super();
		this.folderService = folderService;
	}

	@RequestMapping(method = RequestMethod.POST)
	@ResponseStatus(value = HttpStatus.CREATED)
	public @ResponseBody Folder addFolder(@RequestBody Folder folder) {
		return folderService.save(folder);
	}

	@RequestMapping(value="{id}",method = RequestMethod.GET)
	@ResponseStatus(value = HttpStatus.OK)
	public @ResponseBody Folder getFolder(@PathVariable String id) {
		return folderService.findOne(id);
	}
}
